package com.ming.websocket.controller;

import com.ming.websocket.bean.Message;
import com.ming.websocket.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/api/test")
public class TestController {

    @Autowired
    private TestService testService;


    @GetMapping("/")
    public String index(){
        return "index";
    }
    @RequestMapping("/pushMsg")
    @ResponseBody
    public Map<String,Object> pushMsg(@RequestBody Message message){
        System.out.println("执行controller..");
        testService.printTime();
        Map<String, Object> res =  new HashMap<String, Object>();
        res.put("code",200);
        res.put("msg","success");
        return res;
    }

}
